package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketPrice;
import cn.icanci.ladybird.dao.TicketPriceDao;
import cn.icanci.ladybird.service.TicketPriceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketPrice)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:44:45
 */
@Service("ticketPriceService")
public class TicketPriceServiceImpl implements TicketPriceService {
    @Resource
    private TicketPriceDao ticketPriceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketPriceId 主键
     * @return 实例对象
     */
    @Override
    public TicketPrice queryById(Long ticketPriceId) {
        return this.ticketPriceDao.queryById(ticketPriceId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketPrice> queryAllByLimit(int offset, int limit) {
        return this.ticketPriceDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketPrice 实例对象
     * @return 实例对象
     */
    @Override
    public TicketPrice insert(TicketPrice ticketPrice) {
        this.ticketPriceDao.insert(ticketPrice);
        return ticketPrice;
    }

    /**
     * 修改数据
     *
     * @param ticketPrice 实例对象
     * @return 实例对象
     */
    @Override
    public TicketPrice update(TicketPrice ticketPrice) {
        this.ticketPriceDao.update(ticketPrice);
        return this.queryById(ticketPrice.getTicketPriceId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketPriceId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketPriceId) {
        return this.ticketPriceDao.deleteById(ticketPriceId) > 0;
    }
}